package cn.wei.reallyEnjoy.home.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import cn.wei.reallyEnjoy.R;
import cn.wei.reallyEnjoy.home.bean.CommentBean;
import cn.wei.reallyEnjoy.utils.Constants;

public class CommentAdapter extends BaseAdapter {
    private static final String TAG = "null";
    private final Context mContext;
    private final List<CommentBean> datas;

    public CommentAdapter(Context mContext, List<CommentBean> datas) {
        this.mContext = mContext;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null) {
            convertView =View.inflate(mContext,R.layout.comment_list_item,null);
        }
        ImageView comment_headimg = convertView.findViewById(R.id.comment_headimg);
        TextView comment_name = convertView.findViewById(R.id.comment_name);
        TextView comment_time = convertView.findViewById(R.id.comment_time);
        TextView comment_content = convertView.findViewById(R.id.comment_content);
        CommentBean commentBean = datas.get(position);
        Glide.with(mContext).load(Constants.IMG_URL+commentBean.getHeadImg()).into(comment_headimg);
        comment_name.setText(commentBean.getNickName());
        comment_time.setText(commentBean.getCreateTime());
        comment_content.setText(commentBean.getBody());
        Log.e(TAG,"显示评论");
        return convertView;
    }
}
